﻿@model SiteNavEditGetViewModel
@{
    ViewBag.Title = "编辑菜单";
}

<article class="page-container">
    <form class="form form-horizontal" id="form">
        <input type="hidden" name="id" value="@Model.SiteNav.Id" />
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>功能分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box" style="width:150px;">
                    @Html.DropDownList("functionalModule", (SelectList)Model.ListFun, new { @class = "select" })
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上级菜单：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box" style="width:150px;">
                    @Html.DropDownList("parentNav", (SelectList)Model.ListSiteNav, new { @class = "select" })
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>菜单名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.SiteNav.NavName" placeholder="" id="navName" name="navName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">链接地址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.SiteNav.NavUrl" placeholder="" id="navUrl" name="navUrl">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>打开方式：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box" style="width:150px;">
                    @Html.DropDownList("navTarget", (SelectList)Model.ListNavTarget, new { @class = "select" })
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">是否显示：</label>
            <div class="formControls col-xs-8 col-sm-9 check-box-list">
                <span class="select-box" style="width:150px;">
                    @Html.DropDownList("isShow", (SelectList)Model.ListIsShow, new { @class = "select" })
                </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">菜单Banner：</label>
            <div class="formControls col-xs-8 col-sm-9 check-box-list">
                <div id="navImg" class="uploader uploadImg"></div>

                <p class="c-red pt-5">图片尺寸：000 × 000 像素</p>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
            <div class="formControls col-xs-8 col-sm-9 check-box-list">
                <input type="text" class="input-text" value="@Model.SiteNav.Sort" placeholder="" id="sort" name="sort" style="width:80px;">
                <p class="c-red pt-5">排序数值越小越靠前</p>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">其他说明：</label>
            <div class="formControls col-xs-8 col-sm-9 check-box-list">
                <p>1.首页（功能分类：其他链接 ，链接地址：/Default.html）</p>
                <p>2.选择功能分类中的“其他链接”</p>
                <p>（1）链接地址未确定，用“#”代替</p>
                <p>（2）站外链接必须带http://，例如：http://www.baidu.com</p>
                <p>3.是否显示：是否在前台菜单中显示</p>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius" id="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
            </div>
        </div>
    </form>
</article>

@section FooterScript
{
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="~/Areas/WebAdmin/FrontLib/jquery.validation/1.14.0/messages_zh.js"></script>
    <!--上传文件-->
    <script src="~/Areas/WebAdmin/FrontLib/uploader/uploadFiles.js"></script>
    <script type="text/javascript">
        $(function () {
            //上传图片
            $("#navImg").uploadImages({
                imgUrl: "@Model.SiteNav.NavImg",
                thumbWidth: 150
            });

            //初始化菜单链接 Input 状态
            var $functionalModule = $("#functionalModule");
            var $navUrl = $("#navUrl");
            $navUrl.prop("disabled", $functionalModule.val() != "Other");
            $functionalModule.change(function () {
                $navUrl.prop("disabled", $(this).val() != "Other");
            });

            $("#form").validate({
                rules: {
                    funName: {
                        required: true
                    },
                    funCode: {
                        required: true
                    },
                    sort: {
                        required: true,
                        digits: true
                    }
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    //禁用保存按钮，防止重复提交
                    $("#submit").prop("disabled", true);

                    $(form).ajaxSubmit({
                        type: 'POST',
                        url: "/WebAdmin/SiteNav/Edit",
                        success: function (res) {
                            if (res.status == "ok") {
                                parent.layer.msg('修改成功!', { icon: 1, time: 1000 }, function () {
                                    parent.$('.btn-refresh').click();
                                    //parent.location.reload(); //刷新父页面
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                });
                            } else if (res.status == "redirect") {
                                location.href = res.data;
                            } else if (res.status == "error") {
                                layer.msg(res.errorMsg, { icon: 2, time: 1000 });
                                //解除禁用
                                $("#submit").prop("disabled", false);
                            } else {
                                layer.msg("修改失败", { icon: 2, time: 1000 });
                                //解除禁用
                                $("#submit").prop("disabled", false);
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg('网络出错!', { icon: 2, time: 1000 });
                            //解除禁用
                            $("#submit").prop("disabled", false);
                        }
                    });
                }
            });
        });
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
}


